import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QHBoxLayout, QPushButton, QLineEdit, QGroupBox, QVBoxLayout, QDesktopWidget

from main_handler import main_handler

def start():
    app = QApplication(sys.argv)
    window = QWidget()
    main_handler.window = window
    window.setWindowTitle("Autopic")
    window.setGeometry(100, 100, 600, 400)

    # 获取屏幕尺寸
    qr = window.frameGeometry()
    cp = QDesktopWidget().availableGeometry().center()

    # 将窗口居中显示
    qr.moveCenter(cp)
    window.move(qr.topLeft())

    layout = QHBoxLayout()

    left_group = QGroupBox("显示区域")
    left_layout = QVBoxLayout()

    left_group.setLayout(left_layout)
    layout.addWidget(left_group, 7)

     # 创建一个QLabel标签
    label = QLabel("Hello World")
    main_handler.label = label
    # 将标签添加到布局管理器中
    left_layout.addWidget(label)

    right_group = QGroupBox("操作区域")
    right_layout = QVBoxLayout()

    right_group.setLayout(right_layout)
    layout.addWidget(right_group, 3)

    # 创建一个QPushButton按钮
    button_auto = QPushButton("自动匹配时间")
    button_auto.clicked.connect(main_handler.handler_pic_show_time)
    right_layout.addWidget(button_auto)

    # 创建一个QPushButton按钮
    button_getpos = QPushButton("获取鼠标位置")
    button_getpos.clicked.connect(main_handler.get_mouse_pos)
    right_layout.addWidget(button_getpos)

    window.setLayout(layout)
    window.show()

    sys.exit(app.exec_())

start()
